from functools import cache
from typing import List


class Solution:
    @cache
    def diffWaysToCompute(self, expression: str) -> List[int]:
        if expression.isdigit():
            return [int(expression)]
        ans = []
        for i in range(len(expression)):
            w = expression[i]
            if w in "+-*":
                left = self.diffWaysToCompute(expression[:i])
                right = self.diffWaysToCompute(expression[i + 1:])
                for l in left:
                    for r in right:
                        ans.append(self.compute(l, r, w))
        return ans

    def compute(self, left, right, operation):
        if operation == '+':
            return left + right
        elif operation == '-':
            return left - right
        else:
            return left * right